﻿@using Abp.Authorization.Users
@using Abp.Configuration
@using Abp.Zero.Configuration
@using Snow.Template.Authorization.Users
@model Snow.Template.Web.Models.Users.CreateOrEditUserModalViewModel
<ul class="nav nav-tabs" role="tablist">
    <li class="nav-item">
        <a href="#UserInformationsTab" class="nav-link active" data-toggle="tab" role="tab">
            @L("UserInformations")
        </a>
    </li>
    <li class="nav-item">
        <a href="#RolesTab" data-toggle="tab" role="tab" class="nav-link">
            @L("Roles") <b class="badge badge-primary"><span id="assigned-role-count">@Model.AssignedRoleCount</span></b>
        </a>
    </li>
</ul>
<div class="tab-content">
    <div class="tab-pane active" id="UserInformationsTab" role="tabpanel">
        <form id="modelForm" name="UserInformationsForm" role="form" novalidate>
            @if (Model.IsEditMode)
            {
                <input type="hidden" name="Id" value="@Model.User.Id" />
            }
            <div class="form-group">
                <label asp-for="User.UserName"></label>
                @{
                    if (!Model.CanChangeUserName)
                    {
                        <input asp-for="User.UserName" disabled class="form-control" placeholder="@Html.DisplayNameFor(model => model.User.UserName)">
                        <span class="text-danger">@L("CanNotChangeAdminUserName")</span>
                    }
                    else
                    {
                        <input asp-for="User.UserName" class="form-control" placeholder="@Html.DisplayNameFor(model => model.User.UserName)">
                        <span asp-validation-for="User.UserName" class="text-danger"></span>
                    }
                }
            </div>
            <div class="form-row">
                <div class="form-group col-md-6">
                    <label asp-for="User.Surname"></label>
                    <input asp-for="User.Surname" type="text" class="form-control" placeholder="@Html.DisplayNameFor(model => model.User.Surname)">
                    <span asp-validation-for="User.Surname" class="text-danger"></span>
                </div>
                <div class="form-group col-md-6">
                    <label asp-for="User.Name"></label>
                    <input asp-for="User.Name" type="text" class="form-control" placeholder="@Html.DisplayNameFor(model => model.User.Name)">
                    <span asp-validation-for="User.Name" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="User.EmailAddress"></label>
                <input asp-for="User.EmailAddress" type="email" class="form-control" placeholder="@Html.DisplayNameFor(model => model.User.EmailAddress)">
                <span asp-validation-for="User.EmailAddress" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="User.PhoneNumber"></label>
                <input asp-for="User.PhoneNumber" type="number" class="form-control" placeholder="@Html.DisplayNameFor(model => model.User.PhoneNumber)">
                <span asp-validation-for="User.PhoneNumber" class="text-danger"></span>
            </div>
            @if (!Model.IsEditMode)
            {
                <div class="form-group">
                    <label asp-for="User.Password"></label>
                    <input asp-for="User.Password" type="password" class="form-control" placeholder="@Html.DisplayNameFor(model => model.User.Password)">
                    <span asp-validation-for="User.Password" class="text-danger"></span>
                </div>
            }
            <div class="form-check">
                <input asp-for="User.IsActive" type="checkbox" class="form-check-input">
                <label asp-for="User.IsActive" class="form-check-label"></label>
            </div>
            @*@if (SettingManager.GetSettingValue<bool>(AbpZeroSettingNames.UserManagement.UserLockOut.IsEnabled))
                {
                    <div class="form-check">
                        @if (Model.User.IsLockoutEnabled)
                        {
                            <input asp-for="User.IsLockoutEnabled" type="checkbox" class="form-check-input" value="true" checked="checked" placeholder="@Html.DisplayNameFor(model => model.User.IsLockoutEnabled)">
                        }
                        else
                        {
                            <input asp-for="User.IsLockoutEnabled" type="checkbox" class="form-check-input" value="true" placeholder="@Html.DisplayNameFor(model => model.User.IsLockoutEnabled)">
                        }
                        <label asp-for="User.IsLockoutEnabled" title="@L("IsLockoutEnabled_Hint")" class="form-check-label"></label>
                    </div>
                }*@
            @*<label for="EditUser_IsActive" class="m-checkbox">
                    <input id="EditUser_IsActive" type="checkbox" name="IsActive" value="true" @Html.Raw(Model.User.IsActive ? "checked=\"checked\"" : "")>
                    @L("Active")
                    <span></span>
                </label>*@
            @*<div class="form-group" style="@(Model.IsEditMode ? "display:block":"display:none")">
                    <label asp-for="User.Password"></label>
                    <input asp-for="User.Password" type="password" class="form-control" placeholder="@Html.DisplayNameFor(model => model.User.Password)">
                    <span asp-validation-for="User.Password" class="text-danger"></span>
                </div>
                <!--增强功能,暂不实现-->
                <div class="m-checkbox-list">
                        <label for="EditUser_SetRandomPassword" class="m-checkbox">
                            <input id="EditUser_SetRandomPassword" type="checkbox" name="SetRandomPassword" value="true" @Html.Raw(Model.IsEditMode ? "" : "checked=\"checked\"") />
                            @L("SetRandomPassword")
                            <span></span>
                        </label>
                    </div>
                    <div class="m-checkbox-list">
                        <label for="EditUser_ShouldChangePasswordOnNextLogin" class="m-checkbox">
                            <input id="EditUser_ShouldChangePasswordOnNextLogin" type="checkbox" name="ShouldChangePasswordOnNextLogin" value="true" @Html.Raw(Model.User.ShouldChangePasswordOnNextLogin ? "checked=\"checked\"" : "")>
                            @L("ShouldChangePasswordOnNextLogin")
                            <span></span>
                        </label>
                        <label for="EditUser_SendActivationEmail" class="m-checkbox">
                            <input id="EditUser_SendActivationEmail" type="checkbox" name="SendActivationEmail" value="true" @Html.Raw(Model.IsEditMode ? "" : "checked=\"checked\"")>
                            @L("SendActivationEmail")
                            <span></span>
                        </label>
                    </div>*@
        </form>
    </div>
    <div class="tab-pane" id="RolesTab" role="tabpanel">
        <div class="user-role-checkbox-list">
            @foreach (var role in Model.Roles)
            {
                <div class="m-checkbox-list">
                    <label for="EditUser_@(role.RoleName)" class="m-checkbox">
                        <input id="EditUser_@(role.RoleName)" type="checkbox" name="@(role.RoleName)" value="true" @Html.Raw(role.IsAssigned ? "checked=\"checked\"" : "")>
                        @role.RoleDisplayName
                        <span></span>
                    </label>
                </div>
            }
        </div>
    </div>
</div>
<script type="text/javascript">
    $.validator.unobtrusive.parse('form');
</script>